
// import TableList from "@components/templates/tablelist";
import TableList from "@components/templates/customtablelist";
import { HttpFreezeAndUnfreeze, HttpFreezeTotal } from '@/service/api/views'
import { mapState,mapGetters } from "vuex";
// import compAdd from './add';
import compTrackDetail from './trackdetail';
export default {
    mixins: [TableList],
    components: {
        compTrackDetail,
        // compAdd,
    },
    data() {
        return {
            // totals: 0,
            isMixin: true,
            Tools: {show: true},
            Tabs: {show: true},
            formData:{
                search:{
                }
            },
            Searchs: {
                show: true,
                labelWidth: 120,
            },
            Plugins: {show: true},
            totalnum:'',
            exportData:{},
        }
    },
    methods: {
        ajaxRequest: HttpFreezeAndUnfreeze,
        interceptRequest(params){
            if(params.search.BT_createdAt&&params.search.BT_createdAt[0]!=''){
                params.search.BT_createdAt = this.handleDateFormat(params.search.BT_createdAt[0],'yyyy-mm-dd') + ' ~ ' +this.handleDateFormat(params.search.BT_createdAt[1],'yyyy-mm-dd')
            }
            this.exportData = params;
            return params
        },
        handleOperates(params="", type,batch) {
            if(batch===true){
                params=(params||this.checkedData.join(','))+'';
                if(!params.length) return this.$Message.warning('请选择至少一条数据');
            }
            switch (type) {
                case 'download':
                    this.handleWebfs(
                        process.env.VUE_APP_APIURL_SHIP + "/api/jwt/spl/freeze/exportFreeze",{...this.exportData},
                        "download"
                    );
                    break;
                case 'queryTrack':
                    this.operate = {
                        show:true,
                        title:'查看运单',
                        width:'1000px',
                        trackingNo:params,
                        component:'compTrackDetail',
                        showFooter:false,
                    }
                    break;
                
            }
        },
    },
    computed: {
        ...mapGetters('diction',['getNewDifferentAllProductList','getNewAccountList']),
        // 搜索下拉框展示内容
        SearchsData() {
            return  [
                {
                    label: '运单号',
                    tag: 'Input',
                    key: 'EQ_trackingNo',
                    show:true,
                },
                {
                    label: '创建时间',
                    tag: 'DatePicker',
                    key: 'BT_createdAt',
                    props:{
                        options:this.options,
                        type:'daterange',
                    },
                    show:true,
                    // hideSearchTip:true,
                    style: "width:200px",
                },
            ]
        },
        ToolsData(){
            return [
                {
                    name: "导出",
                    theme: 'success',
                    operate: 'download',
                },
            ]
        },
        // table的展示数据
        columns() {
            return [{
                title: "运单号",
                key: "trackingNo",
                render:(h,{row})=> {
                    return <div>
                        <a onClick={this.handleOperates.bind(this, row.trackingNo, 'queryTrack')}>{row.trackingNo}</a>
                    </div>
                },
            },{
                title: "来源单号",
                key: "sourceNo",
            },{
                title: "承运商/承运商服务",
                render:(h,{row})=>{
                    return <div>
                        <div>{row.carrier}</div>
                        <div>{row.serviceCode}</div>
                    </div>
                }
            },{
                title: "预估金额/币种",
                key: "amount",
                sortable: true,
                render:(h,{row})=>{
                    return <div>
                        <div>{row.amount} ({row.currency})</div>
                    </div>
                }
            }, {
                title: "描述",
                key: "cause",
                maxWidth: 200,
            }, {
                title: "创建时间",
                key: "createdAt",
                sortable: true,
            }, 
        ];
        },
        
    },

};
